package com.attms.controller;


import com.attms.controller.utils.R;
import com.attms.domain.Absent;
import com.attms.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Team
 * @since 2022-12-18
 */
@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private IEmployeeService iEmployeeService;

    // 根据员工id签到
    @GetMapping("/signin/{id}")
    public R signIn(@PathVariable Integer id){
        return new R(iEmployeeService.signIn(id));
    }

    // 根据员工id签出
    @GetMapping("/signout/{id}")
    public R signOut(@PathVariable Integer id){
        return new R(iEmployeeService.signOut(id));
    }

    
    @GetMapping("/state/{id}")
    public R getState(@PathVariable Integer id){
        return new R(true,iEmployeeService.getState(id));
    }

    @GetMapping("/restvocation/{id}")
    public R restVocation(@PathVariable Integer id){
        return new R(true, iEmployeeService.findRestLeave(id));
    }
    @PostMapping
    public R askForLeave(@RequestBody Absent absent){
        return new R(true, iEmployeeService.askForLeave(absent));
    }
    @GetMapping("/absentlist/{myid}")
    public R getAbsentlist(@PathVariable(value = "myid") Integer myid) {
        return new R(true, iEmployeeService.getAbsentList(myid));
    }

}

